<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="cfn" uri="http://francetelecom.com/cfn"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@page import="org.springframework.validation.Errors"%>

<%-- Creates a form text input. Parameters are :
    - code : the label code for the input
    - path : the path for the input
    - maxLength : the max length for the text. If not set, the value is 300.
    - focused : value must be "focused" to focus the input
    - mandatory : optional, boolean string value, 'true' if the field is mandatory.
    - password : optional, boolean string value, 'true' if the value to enter is a password.
    - usePartialValue : optional, boolean string value, 'true' if the related label info box
      must display a label notifying the user that he can use partial values.
    - type :  optional, the type for the input (default is text).
 --%>

<c:set var="type"
  value="${empty param.type ? 'text' : param.type}"/>

<c:set var="maxLength"
  value="${empty param.maxLength ? '300' : param.maxLength}"/>

<jsp:include page="form-field-header.jsp">
  <jsp:param name="code" value="${param.code}"/>
  <jsp:param name="mandatory" value="${param.mandatory}"/>
  <jsp:param name="usePartialValue" value="${param.usePartialValue}"/>
</jsp:include>

<%-- Displaying the form field --%>
<c:choose>
<c:when test="${param.password == 'true'}">
  <form:password cssErrorClass="error" path="${param.path}" maxlength="${maxLength}"
          cssClass="${param.focused}"/>
</c:when>
<c:otherwise>
  <form:input cssErrorClass="error" path="${param.path}" maxlength="${maxLength}"
          cssClass="${param.focused}" type="${type}"/>
</c:otherwise>
</c:choose>

<%-- Displaying the form field error message --%>
<jsp:include page="form-field-errors.jsp">
  <jsp:param name="path" value="${param.path}"/>
</jsp:include>

<jsp:include page="form-field-footer.jsp"/>